//
//  JEHLabel.m
//  CapriceMusic
//
//  Created by 蒋恩浩 on 16/1/8.
//  Copyright © 2016年 MYX. All rights reserved.
//

#import "JEHLabel.h"

@interface JEHLabel ()


@end

@implementation JEHLabel

- (instancetype)initWithFrame:(CGRect)frame withFont:(NSInteger)font withTextColor:(UIColor *)color {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        self.font = [UIFont systemFontOfSize:font];
        self.textColor = color;
    }
    return self;
}

- (void)attributedText:(NSString *)attributedText withFont:(NSInteger)font withColor:(UIColor *)color {

    NSRange range = [self.text rangeOfString:attributedText];
    NSMutableAttributedString *heightLightString = [[NSMutableAttributedString alloc] initWithString:self.text];
    [heightLightString setAttributes:@{NSForegroundColorAttributeName : color, NSFontAttributeName : [UIFont systemFontOfSize:font]} range:range];
    self.attributedText = heightLightString;
}

- (CGFloat)getWidthWithFont:(CGFloat)font {
    NSDictionary *dic = @{NSFontAttributeName : [UIFont systemFontOfSize:font]};
    CGRect rect = [self.text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX,0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.width;
}

- (CGFloat)getHeightWithFont:(CGFloat)font {
    NSDictionary *dic = @{NSFontAttributeName : [UIFont systemFontOfSize:font]};
    CGRect rect = [self.text boundingRectWithSize:CGSizeMake(0, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}

@end











